# encoding: utf-8
from flask_marshmallow import base_fields
from app.modules.common.parameters import BaseParameters, Parameters

class CreateIntegrationPlanParameters(BaseParameters):
    year = base_fields.Integer(
        description = "年",
        required = True
    )
    week = base_fields.Integer(
        description = "周",
        required = True
    )


class IntegrationBaseParameters(BaseParameters):
    integration_name = base_fields.String(
        description = "集成计划名",
        required = True
    )
    integration_id = base_fields.String(
        description = "集成计划id",
        required = False,
        missing = None
    )

class IntegrationIdBaseParameters(BaseParameters):
    integration_id = base_fields.String(
        description = "集成计划id",
        required = True
    )

class IntegrationBaseFalseParameters(BaseParameters):
    integration_id = base_fields.String(
        description = "集成计划id",
        required = False,
        missing = None
    )
    integration_name = base_fields.String(
        description = "集成计划名",
        required = False,
        missing = None
    )
    isEmergency = base_fields.String(
        description = "集成计划类型,为空时查询普通计划,不传为所有计划,0为紧急计划,1为普通计划",
        required = False,
        enum = ['0', '1'],
        missing = None
    )
    hasProList = base_fields.Boolean(
        description = "是否包含工程列表",
        required = False,
        missing = 'false'
    )

class SaveIntegrationInfoParameters(IntegrationBaseParameters):
    """
    保存集成计划内项目及工程信息
    """
    plan_list = base_fields.String(
        description = "项目名称列表",
        required = True
    )
    project_list = base_fields.String(
        description = "集成合并后工程信息列表 工程信息包括:trunk_name,selectPlan",
        required = True
    )
    isDeloy = base_fields.Boolean(
        description = "是否立即部署集成环境",
        required = True,
        missing = 'true'
    )
    isEmail = base_fields.Boolean(
        description = "是否发送邮件通知QA人员",
        required = True,
        missing = 'true'
    )


class GetIntegrationProjectInfoListParameters(IntegrationBaseParameters):
    status = base_fields.String(
        description = "集成计划内工程的状态",
        required = False,
        missing = None
    )
    isHideMergePro = base_fields.Boolean(
        description = "是否隐藏被合并工程",
        required = True,
        missing = 'false'
    )
    withEmergency = base_fields.Boolean(
        description = "是否返回紧急项目",
        required = False,
        missing = 'false'
    )


class DisableProjectPlanInIntegrationParameters(IntegrationBaseParameters):
    plan_name = base_fields.String(
        description = "项目名",
        required = True,
    )


class UpdateProjectConfigParameters(IntegrationBaseParameters):
    config_list = base_fields.String(
        description = "配置文件信息列表",
        required = True,
        missing = None
    )


class UpdateIntegrationStatusParameters(IntegrationBaseParameters):
    new_status = base_fields.String(
        description = "新状态",
        required = True,
    )


class sqlUploadParameters(IntegrationBaseParameters):
    project_name = base_fields.String(
        description = "工程名",
        required = True,
    )
    dir = base_fields.String(
        description = "需要创建文件夹时的相对路径",
        required = False,
        missing = None
    )


class sqlDownloadParameters(IntegrationBaseParameters):
    trunk_name = base_fields.String(
        description = "主干工程名",
        required = True,
    )
    filename = base_fields.String(
        description = "文件名",
        required = True,
    )


class saveProjectSqlInfoParameters(Parameters):
    integration_id = base_fields.String(
        description = "集成计划id",
        required = True,
    )
    list = base_fields.String(
        description = "sql文件信息列表",
        required = True,
    )

class checkProjectSqlParameters(Parameters):
    integration_id = base_fields.String(
        description = "集成计划id",
        required = True,
    )
    trunk_name = base_fields.String(
        description = "主干工程名",
        required = True,
    )
    file_name = base_fields.String(
        description = "sql文件名",
        required = True,
    )
    status = base_fields.String(
        description = "状态",
        enum = ['0','1'],
        required = True,
    )

class AddPlanForIntegrationParameters(IntegrationIdBaseParameters):
    plan_id = base_fields.String(
        description = "项目id",
        required = True
    )

class SaveIntegrationOnlineDescParameters(IntegrationIdBaseParameters):
    desc_id = base_fields.String(
        description = "集成计划上线描述id",
        required = False,
        missing = None
    )
    desc = base_fields.String(
        description = "集成计划上线描述",
        required = True
    )

class CreateEmergencyIntegrationPlanParameters(BaseParameters):
    emergency_plan_id = base_fields.String(
        description = "紧急项目id",
        required = True
    )

class UploadOnlineDescFileParameters(IntegrationBaseParameters):
    desc_id = base_fields.String(
        description = "备注id",
        required = True,
    )

class DownloadFileParameters(BaseParameters):
    file_name = base_fields.String(
        description = "文件名",
        required = True,
    )
    file_path = base_fields.String(
        description = "文件路径",
        required = True,
    )